import { createRouter, createWebHistory } from 'vue-router'
import { usePortStore } from '@/stores/index'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [

    {
      path: '/',
      name: 'home',
      component: () => import('@/views/home/index.vue'),

    },
    {
      path: '/detail',
      name: 'detail',
      component: () => import('@/views/detail/index.vue'),

    },
  ]
})



// router.beforeEach((to, from, next) => {
//   const { setPort, getPort, isInvalid } = usePortStore()
//   if (to.path !== '/login' && isInvalid()) {
//     console.log(from, "rom")
//     setPort({})
//     next(`/login`)
//   }
//   if (to.path === '/login' && !isInvalid()) {
//     next('/knowledge')
//   }
//   if (to.path === '/nas') {
//     // window.location.href = 'http://ts.aipocket-nas.igrsservice.com/#/'
//   }
//   next()
// })

export default router
